import logging
from redis import StrictRedis


class Config(object):

    DEBUG = True

    SECRET_KEY = "EjpNVSNQTyGi1VvWECj9TvC/+kq3oujee2kTfQUs8yCM6xX9Yjq52v54g+HVoknA"
    # 数据库的配置信息
    SQLALCHEMY_DATABASE_URI = "mysql://root:mysql@127.0.0.1:3306/infor20191113"
    SQLALCHEMY_TRACK_MODIFICATIONS = False
    # redis
    REDIS_HOST = '127.0.0.1'
    REDIS_PORT = 6379
    # session
    SESSION_TYPE = 'redis'
    # 开启session签名
    SESSION_USE_SIGNER = True  # 让 cookie 中的 session_id 被加密签名处理
    SESSION_REDIS = StrictRedis(host=REDIS_HOST, port=REDIS_PORT)  # 使用 redis 的实例
    PERMANENT_SESSION_LIFETIME = 86400  # session 的有效期，单位是秒

    # 设置日志等级
    LOG_LEVEL = logging.DEBUG


class DevelopementConfig(Config):
    """开发模式下的配置"""
    DEBUG = True
    # 设置日志等级
    LOG_LEVEL = logging.WARNING


class ProductionConfig(Config):
    """生产模式下的配置"""
    DEBUG = False


# 定义配置字典
config = {
    "development": DevelopementConfig,
    "production": ProductionConfig
}